package edu.mtu.citizenscience.mushroommapper.model.report;

import java.util.Date;

import com.openswimsoftware.orm.model.ModelFile;
import com.openswimsoftware.orm.model.annotation.Parent;

import android.content.Context;

import edu.mtu.citizenscience.mushroommapper.model.ModelReport;

/**
 * @author Corbin Uselton <corbinu@cwuselto@mtu.edu>
 * @copyright (c) 2012 MichiganTech <http://www.mtu.edu>
 * @since 1.0
 * 
 * Model of report image in the app DB belongs to a report has a date and image path
 */
public class ModelImage extends ModelFile<ModelImage> {
	// reference var for passing image model id between activities
	public static final String IMAGE_ID = "IMAGE_ID";
	
	// the images part report
	@Parent
	private ModelReport report;
	
	// the image num
	private int num;
	// the date the image was taken
	private Date date;
	
	/**
	 * Create the image model
	 * 
	 * @param   context - Context - context for model operations
	 * @return	void
	 */
	public ModelImage(Context context) 
	{
		super(context, ModelImage.class);
	}

	/**
	 * Create the image model
	 * 
	 * @param   context - Context - context for model operations
	 * @param	id - long - the id of the model to load
	 * @return	void
	 */
	public ModelImage(Context context, long id) 
	{
		super(context, ModelImage.class, id);
	}
	
	/**
	 * Get the image num
	 * 
	 * @param   void
	 * @return	int - the image num
	 */
	public int getNum()
	{
		// make sure the model is loaded
		this.load();
		
		return this.num;
	}
	
	/**
	 * Set the image num
	 * 
	 * @param   num - int - the image num
	 * @return	void
	 */
	public void setNum(int num)
	{
		// mark the model as updated
		this.updated = true;
		
		this.num = num;
	}
	
	/**
	 * Get the image date
	 * 
	 * @param   void
	 * @return	Date - date the image was taken
	 */
	public Date getDate()
	{
		// make sure the model is loaded
		this.load();
		
		return this.date;
	}
	
	/**
	 * Set the image date
	 * 
	 * @param   date - Date - date the image was taken
	 * @return	void
	 */
	public void setDate(Date date)
	{
		// mark the model as updated
		this.updated = true;
		
		this.date = date;
	}
	
	/**
	 * Get the image parent report
	 * 
	 * @param   void
	 * @return	ModelReport - the parent report
	 */
	public ModelReport getReport()
	{
		// make sure the model is loaded
		this.load();
		
		return this.report;
	}
	
	/**
	 * Set the image parent report
	 * 
	 * @param   report - ModelReport - the parent report
	 * @return	void
	 */
	public void setReport(ModelReport report)
	{
		// mark the model as updated
		this.updated = true;
		
		this.report = report;
	}

}
